public class MyDeque<E> implements Deque<E> {
    DList<E> v;
    int      size;

    public MyDeque() {
    v    = new DList<E>();
    size = 0;
    }

    public int size() {
    return ( v.size() );
    }

    public boolean isEmpty() {
    return ( v.isEmpty() );
    }

    public E getFirst() throws EmptyDequeException {
    if( isEmpty() )
        throw new EmptyDequeException( "Deque is empty." );
    DNode<E> temp = v.getFirst();
    E e = temp.getElement();
        return ( e );
    }

    public E getLast() throws EmptyDequeException {
    if( isEmpty() )
        throw new EmptyDequeException( "Deque is empty." );
    DNode<E> temp = v.getLast();
    E e = temp.getElement();
        return ( e );
    }

    public void addFirst( E element ) {
    DNode<E> node = new DNode<E>( element, null, null );
    v.addFirst( node );
    }

    public void addLast( E element ) {
    DNode<E> node = new DNode<E>( element, null, null );
    v.addLast( node );
    }

    public E removeFirst() throws EmptyDequeException {
    if( isEmpty() )
        throw new EmptyDequeException( "Deque is empty." );
    DNode<E> temp = v.getFirst();
        v.remove( temp );
    return ( temp.getElement() );
    }

    public E removeLast() throws EmptyDequeException {
    if( isEmpty() )
        throw new EmptyDequeException( "Deque is empty." );
    DNode<E> temp = v.getLast();
        v.remove( temp );
    return ( temp.getElement() );
    }

    public String toString() {
    return ( v.toString() );
    }

    }